<template>
  <div class="my">
    <div class="top">
      <div class="imgs">
        <img src="~@/views/my/image/bgc.png" alt="" />
      </div>
      <div class="icon">
        <img
          src="~@/views/my/image/setting.png"
          @click="$router.push('/userinfo')"
          alt=""
        />
      </div>
      <div class="touxiang">
        <div class="img">
          <img :src="userInfo.touxiang" alt="" />
        </div>
        <div class="text">
          <span class="name">{{ userInfo.name }}</span>
          <span class="id">ID:{{ userInfo.nameID }} </span>
        </div>
      </div>
      <div class="money">
        <div class="title">
          <span>总资产（元）</span>
          <van-icon
            :name="isMoney ? 'eye - o' : 'closed-eye'"
            @click="NOmoney"
          />
        </div>
        <div class="concent">
          <div class="num" @click="NOmoney">
            {{ isMoney ? "200000"
        : money.replace(/\d/g, "*").replace(".", ""), }}
          </div>
          <div class="btn">
            <button @click="$router.push('/recharge')">充值</button>
            <button class="xuanzhong" @click="$router.push('/withdraw')">提现</button>
          </div>
        </div>
      </div>
    </div>

    <div class="xiangqing">
      <div class="img">
        <img src="~@/assets/订单记录.png" alt="" 
        @click="$router.push('/update')"
        />
        <img
          src="~@/assets/账变记录.png"
          alt=""
          @click="$router.push({ name: 'AccountChangeRecord' })"
        />
      </div>
      <!-- 个人中心表 -->
      <div class="user">
        <van-row>
          <van-col class="uesr-icon"
            ><img src="~@/assets/账户安全ICO.png" alt="" />
          </van-col>
          <van-col class="anquan">账户安全</van-col>

          <van-icon @click="$router.push('/AccountSecurity')" name="arrow" />
        </van-row>
        <van-row>
          <van-col class="uesr-icon">
            <img src="~@/assets/消息中心ICO.png" alt="" />
          </van-col>
          <van-col class="anquan">消息中心</van-col>
          <van-icon @click="$router.push('/messagecenter')" name="arrow" />
        </van-row>
        <van-row>
          <van-col class="uesr-icon"
            ><img src="~@/assets/在线客服.png" alt="" />
          </van-col>
          <van-col class="anquan">在线客服</van-col>
          <van-icon @click="$router.push('/service')" name="arrow" />
        </van-row>
        <van-row>
          <van-col class="uesr-icon"
            ><img src="~@/assets/好友分享ICO.png" alt="" />
          </van-col>
          <van-col class="anquan">好友分享</van-col>

          <van-icon name="arrow" @click="tangce" />
        </van-row>
        <van-row @click="logout">
          <van-col class="uesr-icon"
            ><img src="~@/assets/退出登录ICO.png" alt="" />
          </van-col>
          <van-col class="anquan">退出登录</van-col>

          <van-icon name="arrow" />
        </van-row>
      </div>
    </div>
    <!-- 组件弹窗 -->
    <van-popup v-model="show">
      <div class="baocun">
        <img class="baocun1" src="../.././assets/保存@3x.jpg" />
      </div>
      <van-button
        class="ok"
        type="primary"
        color="linear-gradient(to right, #FA7D22, #FA461B)"
        >保存到相册</van-button
      >
    </van-popup>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { getUserInfo } from "@/api/user";
export default {
  data() {
    return {
      userInfo: {},
      show: false,
      money: "2000.00",
      isMoney: true,
    };
  },
  methods: {
    logout() {
      this.$dialog
        .confirm({
          title: "确定退出？",
        })
        .then(async () => {
          // 删除TOK
          await this.$store.dispatch("user/logout");
          this.$router.push("/login");
        });
    },
    NOmoney() {
      // this.money = this.money.replace(/\d/g, "*").replace(".", "");
      this.isMoney = !this.isMoney;
    },
    async getUserInfo() {
      const { data } = await getUserInfo(this.token);
      this.userInfo = data;
    },
    tangce() {
      this.show = true;
    },
  },

  computed: {
    ...mapGetters(["token"]),
  },
  created() {
    this.getUserInfo();
  },
};
</script>

<style scoped lang="less">
.my {
  background-color: #f0f0f0;
  height: 100vh;
}
.baocun {
  height: 730px;
  width: 500px;
  border-radius: 20px;
}
.baocun1 {
  height: 730px;
  width: 500px;
  border-radius: 20px;
}
.van-popup {
  background-color: rgba(0, 0, 0, 0);
}
.ok {
  width: 500px;
  height: 80px;
  margin-left: 7px;
  margin-top: 50px;
  border-radius: 50px;
}
.top {
  height: 750px;
  padding: 20px 20px 0;
  position: relative;
  box-sizing: border-box;

  .imgs {
    position: absolute;
    top: 0;
    left: 0;
    width: 750px;
    img {
      width: 750px;
    }
  }
  .icon {
    position: absolute;

    width: 40px;
    height: 40px;
    right: 40px;
    top: 40px;

    color: lightblue;
    img {
      width: 40px;
      height: 40px;
    }
  }
  .touxiang {
    position: absolute;
    top: 120px;
    left: 40px;
    right: 40px;
    display: flex;
    justify-content: start;
    height: 128px;

    .img {
      width: 128px;
      height: 128px;
      border-radius: 50%;
      overflow: hidden;
      // border: 1px solid #fff;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .text {
      display: flex;
      flex-direction: column;
      text-align: start;
      margin-left: 30px;
      justify-content: center;
      .name {
        font-size: 40px;
        font-weight: 700;
      }
      .id {
        font-size: 20px;
        color: #5c5d60;
      }
    }
  }
  .money {
    position: absolute;
    top: 280px;
    left: 20px;
    right: 20px;
    z-index: 1;
    height: 300px;
    background: url(../../assets/mbgc.png) no-repeat;
    background-size: 100%;
    color: #fff;
    .title {
      display: flex;
      justify-content: start;
      align-content: center;
      margin-left: 40px;
      margin-top: 24px;
      span {
        font-size: 38px;
      }
      .van-icon {
        font-size: 38px;
        margin-top: 10px;
      }
    }
    .concent {
      display: flex;
      justify-content: space-between;
      margin-top: 14px;
      .num {
        font-size: 72px;
        font-weight: 700;
        margin-left: 40px;
      }
      .btn {
        button {
          width: 128px;
          height: 60px;
          border-radius: 30px;
          border: 1px solid #fff;
          background-color: #fff;
          color: #fa7d22;
          font-size: 28px;
          margin-right: 18px;
          line-height: 60px;
        }
        .xuanzhong {
          background-color: #f36d4b;
          color: #fff;
        }
      }
    }
  }
}
.xiangqing {
  position: fixed;
  z-index: 10;
  top: 460px;
  width: 750px;
  height: 650px;
  background: url(../../assets/下色.png);
  opacity: 0.8;
  padding-top: 42px;
  border-radius: 0 0 30px 30px;
  .img {
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    margin-bottom: 40px;
  }
  // biao
  .user {
    padding: 0 20px;
    height: 40px;
    line-height: 40px;
    .van-row {
      margin-bottom: 50px;
      .user-icon {
        float: left;
        width: 40px;
        height: 40px;
        img {
          width: 100%;
        }
      }
      .anquan {
        float: left;
        margin-left: 20px;
        font-size: 28px;
        color: #000;
      }
      .van-icon {
        float: right;
        font-size: 34px;
      }
    }
  }
}
</style>
